package com.shi.yoyoshop.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shi.yoyoshop.bean.Order;
import com.shi.yoyoshop.mapper.OrderMapper;
import com.shi.yoyoshop.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 20556
 * @description 针对表【order】的数据库操作Service实现
 * @createDate 2024-01-05 15:53:54
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order>
        implements OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Override
    public List<Order> getOrderListByUserId(Integer userId) {
        return orderMapper.selectOrderListByUserId(userId);
    }

    @Override
    public Order getOrderById(Integer orderId) {
        return orderMapper.selectOrderById(orderId);
    }

    @Override
    public void saveOrder(Order order) {
        orderMapper.insertOrder(order);
    }

    @Override
    public void updateOrderById(Order order) {
        orderMapper.updateOrderById(order);
    }

    @Override
    public IPage<Order> getOrderListByStatusWithPage(Page<Order> orderPage, Integer status) {
        if (status.equals(0)) {
            status = null;
        }
        return orderMapper.selectOrderPage(orderPage, status);
    }

}




